const KEY = 'hmzs'

export const setToken = token => localStorage.setItem(KEY + '-token', token)
export const getToken = () => localStorage.getItem(KEY + '-token')
export const delToken = () => localStorage.removeItem(KEY + '-token')
export const setRefToken = token => localStorage.setItem(KEY + '-refToken', token)
export const getRefToken = () => localStorage.getItem(KEY + '-refToken')
export const delRefToken = () => localStorage.removeItem(KEY + '-refToken')
export const getSetting = key => {
    const settings = JSON.parse(localStorage.getItem(KEY + '-settings')) || {}
    return settings[key]
}
export const addSetting = (key, value) => {
    const settings = JSON.parse(localStorage.getItem(KEY + '-settings'))
    localStorage.setItem(KEY + '-settings', JSON.stringify({ ...settings, [key]: value }))
}
